#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
/*
Copyright (C) 2013 Johan Ceuppens

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
@class Functor;
#include "SignalC.h"

#define ptr_fun(f) \
	Functor *F = [[Functor alloc] init:f]; \

#define FUNCTORNUMBER(functorclass) \
	fs = STR_EXPAND(functorclass) \
	return fs[7] 

#define FUNCTORSETARGS(functorclass,i) \
	while ( i < 6) \
		void *arg##i++, \
 \
	void *arg##i \

/*
 * A Functor always contains the funtion ptr variable funptr which
 * can be set with 7 args such as in lisp and libsigc++
 */
@interface FunctorX : NSObject
{
	void *(*funptr)(void*, void*,void*,void*,void*,void*,void*);
}

- (id) init:(void*)f;
- (void*)dof;
- (void*)dof:(void*)arg0;//FIXMe use id ?
- (void*)dof:(void*)arg0 arg1:(void*)arg1;
- (void*)dof:(void*)arg0 arg1:(void*)arg1 arg2:(void*)arg2;
- (void*)dof:(void*)arg0 arg1:(void*)arg1 arg2:(void*)arg2 arg3:(void*)arg3;
- (void*)dof:(void*)arg0 arg1:(void*)arg1 arg2:(void*)arg2 arg3:(void*)arg3 arg4:(void*)arg4;
- (void*)dof:(void*)arg0 arg1:(void*)arg1 arg2:(void*)arg2 arg3:(void*)arg3 arg4:(void*)arg4 arg5:(void*)arg5;
- (void*)dof:(void*)arg0 arg1:(void*)arg1 arg2:(void*)arg2 arg3:(void*)arg3 arg4:(void*)arg4 arg5:(void*)arg5 arg6:(void*)arg6;
- (void*)dof:(void*)arg0 arg1:(void*)arg1 arg2:(void*)arg2 arg3:(void*)arg3 arg4:(void*)arg4 arg5:(void*)arg5 arg6:(void*)arg6 arg7:(void*)arg7;

@end

@interface FunctorY
{
	SIGCMReturnType *returnType;
	NSMutableArray *args;
}

- (id) init;
- (SIGCMReturnType*)dof:(NSMutableArray*)array;

@end

/*
 * Functor0 can be made with SIGCMType and SIGCMReturnType
 */

@interface Functor0 : Functor
{
	void*(*funptr)();
}
- (id) init:(void*)f;
- (void*)dof;
- (Functor*)createManipulator;

@end

@interface Functor1 : Functor
{
	void*(*funptr)(void*);
}

- (id) init:(void*)f;
- (void*)dof:(void*)arg0;

@end

@interface Functor2 : Functor
{
	void*(*funptr)(void*,void*);
}

- (id) init:(void*)f;
- (void*)dof:(void*)arg0 arg1:(void*)arg1;

@end



